﻿<cfscript>
/** 
* ORM StudentMarkAduit
* 
* @hint "Hibernate persistenter t_mark_aduit. 成绩操作审计日志" 
* 
*/ 

component 
	displayname="public.service.orm.senate.StudentMarkAduit" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="StudentMarkAduit" 
	table="t_mark_aduit"
	{
	
	property type="string" name="OperID" column="opid" fieldtype="id" generator="assigned" hint="审计编号";
	
	property type="string" name="Operation" column="op_type" hint="变更类别";
	property type="string" name="TimeStamp" column="op_ts" hint="操作时间";
	property type="string" name="IP" column="op_ip" hint="IP地址";
	property type="string" name="Description" column="operation" hint="操作内容";

	property name="Student" fieldtype="many-to-one" fkcolumn="stu_id" cfc="Student"  hint="学生";
	property name="Course" fieldtype="many-to-one" fkcolumn="cid" cfc="Course"  hint="课程";
	property name="Teacher" fieldtype="many-to-one" fkcolumn="tch_id" cfc="Teacher"  hint="教师";
	
	/**
	* @hint "自定义主键规则"
	*/
	public string function getNextID() output=false {
		
		var nextID = DateFormat(now(), "YYYYMMDD") & numberFormat(1, "0_____");
		var checkArray = ORMExecuteQuery("select OperID from StudentMarkAduit 
											where OperID like :condition
											order by OperID desc", { condition=DateFormat(now(), "YYYYMMDD") & "______" }, { maxResults=1 });
		/* 
			主键生成规则 CHAR(14)
			
			8位日期 6位为流水号
		*/
		if (arrayLen(checkArray)) {
			/* 创建一个追加id */
			nextID = DateFormat(now(), "YYYYMMDD") & numberFormat((right(checkArray[1], 6) + 1), "0_____");			
		}

		return nextID;
	}
		
}

</cfscript>